Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPMBE-128] 유저 도착 이벤트를 받아 FCM Message 발송과 알림을 저장한다 #220

Merged
merged 4 commits into from
Jul 20, 2023

Conversation

kdomo
Copy link
Member

@kdomo kdomo commented Jul 20, 2023

개요

작업사항

  • 유저 도착 이벤트를 받아 FCM Message를 발송하고 알림 테이블에 데이터를 저장한다.
  • 자신의 알림 조회 시 '유저 도착' 알림도 조회하도록 추가
  • FCM Message 발송 시 FcmToken 값 != null 로 비교하였는데 always true 로 잠재적인 버그 해결
    (String 값 == 비교, 동일 객체 비교는 === 쓰는거 몰랐었네요 😥)

@kdomo kdomo requested a review from ImNM as a code owner July 20, 2023 09:08
@kdomo kdomo self-assigned this Jul 20, 2023
@kdomo kdomo requested a review from BlackBean99 as a code owner July 20, 2023 09:08
Comment on lines +51 to +79

val promiseUsers = promiseUserAdaptor.findByPromiseId(promiseId)

// 약속에 참여한 유저들 조회 (자기 자신 제외)
val users = promiseUsers
.map { promiseUser -> userAdapter.queryUser(promiseUser.userId) }
.filter { user -> user.id != userId }

// 도착한 유저
val arrivalUser = userAdapter.queryUser(userId)

// 앱 알람 허용한 유저
val appAlarmPermitUsers = users
.filter { user -> user.fcmNotification.fcmToken != "" && user.fcmNotification.appAlarm }

val data: MutableMap<String, String> = mutableMapOf()
data["notificationType"] = NotificationType.ARRIVAL.name
data["promiseId"] = promiseId.toString()
data["senderUserId"] = promiseUserUpdateLocationEvent.userId.toString()

// 행정동 조회
val intersects = districtRepository.findByLocationIntersects(
Point(
Position(promise.meetPlace!!.coordinate.longitude, promise.meetPlace!!.coordinate.latitude),
),
)
val district = intersects.properties.adm_nm

// 앱 알람 허용한 유저에게 알람 보내기
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 SRP 준수하게 변경해도 좋을 것 같아요 private 하게 data, intersects district 관련 조회들은 분리해볼 수 있지 않을까요? ㅎㅎ 동작 하기만 하면 상관 없지만 리펙토링 다음에 같이 해요 ㅎ

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fcm 발송하는 쪽 전체적으로 리팩토링이 필요할 것 같아요!!
감사합니다 🙇🏻

@sonarcloud
Copy link

sonarcloud bot commented Jul 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

4.6% 4.6% Coverage
0.0% 0.0% Duplication

@kdomo kdomo merged commit a36acb9 into develop Jul 20, 2023
3 checks passed
@kdomo kdomo deleted the feature/DPMBE-128 branch July 20, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DPMBE-128] 유저 도착 이벤트를 받아 FCM Message 발송과 알림을 저장한다
2 participants